/**
 * @param {string} s
 * @return {boolean}
 */
export var isValid = function (s) {
  const stack = []
  const dt = {
    '(': ')',
    '[': ']',
    '{': '}',
  }
  for (let i = 0; i < s.length; i++) {
    const m = s[i]
    if (m === '(' || m === '[' || m === '{') stack.push(m)
    else if (m !== dt[stack.pop()]) return false
  }
  return stack.length === 0
}
